package com.GainLoop.Api.Entity;

import java.util.Date;

import org.json.JSONException;
import org.json.JSONObject;

import com.GainLoop.Api.ApiException;
import com.facebook.android.FacebookError;
import com.facebook.android.Util;
import com.google.gson.annotations.SerializedName;

public class Link extends EntityAbstract {
	
	public enum STATUS {
		
		STATUS_ACTIVE(0),
		STATUS_CANCELED(-1),
		STATUS_SATISFIED(10),
		STATUS_SUSPENDED(5);
		
		private int code;
		
		private STATUS(int n) {
			   code = n;
		}
		public int getCode() {
			   return code;
			 }
	}

	@SerializedName("id")
	public long _id;

	@SerializedName("gainId")
	public long _gainId;
	
	@SerializedName("fromUserId")
	public long _fromUserId;
		
	@SerializedName("toUserId")
	public long _toUserId;
		
	@SerializedName("createTime")
	private long _createTime;

	@SerializedName("status")
	private STATUS _status;

	@SerializedName("lastUpdateTime")
	public long _lastUpdateTime;


	public long getId()
	{
		return this._id;
	}
	
	public void setId(long id)
	{
		if(id < 0) {
			throw new ApiException("id must be unsigned");
		}
		this._id = id;
	}
	public long getGainId()
	{
		return this._id;
	}
	
	public void setGainId(long gainId)
	{
		if(gainId < 0) {
			throw new ApiException("gainId must be unsigned");
		}
		this._gainId = gainId;
	}
	
	
	public long getFromUserId()
	{
		return this._fromUserId;
	}
	
	public void setFromUserId(long fromUserId)
	{
		this._fromUserId = fromUserId;
	}
	
	public long getToUserId()
	{
		return this._toUserId;
	}
	
	public void setToUserId(long toUserId)
	{
		this._toUserId = toUserId;
	}
	
	public Date getCreateTime()
	{
		return new Date(_createTime * 1000);
	}
	
	public void setCreateTime(Date createTime)
	{
		_createTime = createTime.getTime() / 1000;
	}
	
	public STATUS getStatus()
	{
		return this._status;
	}
	
	public void setStatus(STATUS status)
	{
		_status = status;
	}
	
	public Date getLastUpdateTime()
	{
		return new Date(_lastUpdateTime * 1000);
	}
	
	public void setLastUpdateTime(Date lastUpdateTime)
	{
		_lastUpdateTime = lastUpdateTime.getTime() / 1000;
	}
	public String toString()
	{
		return "Gain[" + this._id + ", from: " + this._fromUserId +", to: " + this._toUserId + "]";
	}
}
